<template>
	<view>
		<view class="select-box">
			<view class="select-box__left">已选择({{list.length}}):</view>
			<view class="select-box__center" @click="selectVisible = true">
				<slot name="center"></slot>
			</view>
			<view class="select-box__right">
				<u-button type="primary" text="确定" color="#3C9CFF" :customStyle="{width: '100rpx',height: '50rpx',fontSize: '25rpx'}" @click="confirm"></u-button>
			</view>
		</view>
		<u-popup :show="selectVisible" :round="10"  :customStyle="{bottom: '100rpx'}" mode="bottom" @close="selectVisible = false" @open="selectVisible = true">
			<view class="select-popup__head">
				已选择
				<view class="select-popup__head--icon" @click="selectVisible = false">
					<u-icon name="close"></u-icon>
				</view>
			</view>
			<view class="popup-box">
				<slot name="popup"></slot>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				selectVisible: false
			}
		},
		props: {
			list: {
				type: Array,
				default: () => []
			}
		},
		methods: {
			confirm() {
				this.$emit('confirm')
			}
		}
	}
</script>

<style>
	.select-box {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		height: 100rpx;
		background-color: #fff;
		border-top: 1rpx solid #eee;
		display: flex;
		align-items: center;
		padding: 0 10rpx;
		box-sizing: border-box; 
		z-index: 99999;
	}
	
	.select-popup__head {
		height: 120rpx;
		text-align: center;
		font-size: 30rpx;
		font-weight: bold;
		line-height: 120rpx;
		position: relative;
		border-bottom: 1rpx solid #eee;
	}
	
	.select-popup__head--icon {
		position: absolute;
		right: 30rpx;
		top: 50%;
		transform: translateY(-50%);
	}
	
	.select-box__left {
		white-space: nowrap;
		margin-right: 20rpx;
	}
	
	.select-box__center {
		width: calc(100% - 290rpx);
		height: 100%;
		display: flex;
		align-items: center;
		overflow-x: scroll;
	}
	
	.select-box__right {
		position: absolute;
		right: 10rpx;
		top: 0;
		height: 100%;
		width: 120rpx;
		background-color: #fff;
		box-sizing: border-box;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	
	.popup-box {
		height: 500rpx;
		overflow-y: scroll;
	}
</style>
